<?php
    $con=mysqli_connect('localhost','root','root','db_chuangbie',3306);
    $username=$_POST['username'];
    $password=$_POST['password'];
    
    $sql="SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password'";
    
    $res=mysqli_query($con,$sql);

    if(!$res){
        die('error for mysql:'.mysqli_error());
    }
    $row=mysqli_fetch_assoc($res);
    if(!$row){
        echo json_encode(array(
            "code"=>0,
            "message"=>"登录失败"
        ));
    }else{
        echo json_encode(array(
            "code"=>1,
            "message"=>"登录成功"
        ));
    }

?>